<?php

namespace app\api\controller;

class My
{
    public $pagesize = 10;

    /**
     * http://127.0.0.1:9093/api/my/userInfo?uid=95
     * 根据UID获取我的个人信息
     */
    public function userInfo()
    {
        $auth = trim(input("request.auth"));//用户auth
        $userInfo = checkLoginExp($auth);
        if (empty($userInfo)) {
            $return = ['err' => 1, 'msg' => '获取失败,未登录', 'devMsg' => '获取失败，参数错误[auth]'];
            return json($return);
        }
        $userInfo = filterUserInfoField($userInfo);
        $userInfo['age']="";
        if($userInfo['bday'])
        {
            $userInfo['age'] = getUserCurrAge($userInfo['bday']);
        }
        $return['err'] = 0;
        $return['msg'] = '获取成功';
        $return['data'] = $userInfo;
        return json($return);
    }


    /**
     * 获取我的金额明细
     */
    public function myMoneyDetailLists()
    {
        $auth = trim(input("request.auth"));//用户auth
        $userInfo = checkLoginExp($auth);
        if (empty($userInfo)) {
            $return = ['err' => 1, 'msg' => '获取失败,未登录', 'devMsg' => '获取失败，参数错误[auth]'];
            return json($return);
        }

        $pagesize = trim(input("pagesize"));//每页条数

        if (!empty($pagesize)) {
            $this->pagesize = $pagesize;
        }
        $w = array();
        $w['uid'] = $userInfo['id'];
        $model = new \app\admin\model\MoneyDetail();
        $lists = $model->lists($w, $this->pagesize);
        $lists = $lists['data'];
        $lists = formateTimeForArr($lists, "ctime");
        $return['err'] = 0;
        $return['msg'] = '获取成功';
        $return['data'] = $lists;
        return json($return);

    }


}
